<?php
$_id = $_POST['_id'];//員工ID
$_license = $_POST['_license'];
$_date = $_POST['_date'];
$_timeSlot = $_POST['_timeSlot'];
$_trackNumber = $_POST['_trackNumber'];

if($_id != 0)
{
	$link=mysql_connect("localhost", "root" ,"1123");
	mysql_select_db("dd") or die("No database");
	
	//刪除貨件at關係
	$query = "	delete from at
				where tracking_number = '" . $_trackNumber . "';";
	echo $query;
	mysql_query($query) or die("Error Message:".mysql_error());
	
	//新增任務
	$query = "Insert into delivery_period values('" . $_license . "', '" . $_date . "', '" . $_timeSlot . "');";
	echo $query;
	mysql_query($query) or die("Error Message:".mysql_error());
	
	//新增員工-任務
	$query = "Insert into work values('" . $_id . "', '" . $_license . "', '" . $_date . "', '" . $_timeSlot . "');";
	echo $query;
	mysql_query($query) or die("Error Message:".mysql_error());
	
	//新增貨物-任務
	$query = "Insert into deliver values('" . $_trackNumber . "', '" . $_license . "', '" . $_date . "', '" . $_timeSlot . "');";
	echo $query;
	mysql_query($query) or die("Error Message:".mysql_error());
	
	mysql_close ($link);
}
?>